package com.site.web;

import com.night.common.entity.ResultVo;
import com.night.common.entity.logistical.Area;
import com.site.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @ClassName: AreaController
 * @author: LJC
 * @date: 2022/10/24-10:24
 * 场地
 */
@RestController
@RequestMapping("/api/lot/area")
public class AreaController {
    @Autowired
    private AreaService areaService;

    //添加场地接口
    @RequestMapping("/add")
    public ResultVo<?> add(Area area){
        areaService.addArea(area);
        return ResultVo.SUCCESS;
    }

    //查询所有场地信息
    @RequestMapping("/getAll")
    public ResultVo<?> getAll(){
        List<Area> list = areaService.getAll();
        return new ResultVo(200,"OK",list);
    }

    //根据id查询场地信息
    @RequestMapping("/getAreaById")
    public ResultVo<?> getAreaById(Area area){
        Area area1 = areaService.getAreaById(area);
        return ResultVo.SUCCESS;
    }

    //修改场地信息
    @RequestMapping("/update")
    public ResultVo<?> updateArea(Area area){
        areaService.updateArea(area);
        return ResultVo.SUCCESS;
    }

    //根据场地类型查找
    @RequestMapping("/getAreaType")
    public ResultVo<?> getAreaType(@RequestBody Area area){
        List<Map<String, String>> list = areaService.getAreaByareaType(area);
        System.out.println("接收信息");
        return new ResultVo(200,"OK",list);
    }

}
